<script setup>
import { inject, ref } from "vue";
// import stepsview from "../components/steps/steps.vue";
import { useCounterStore } from "@/stores/upgrade";
import { handleGoBack } from "@/utils/router";
import { upgradecreate, upgradeagreeInfo } from "@/services/upfrade";
import { uploadfile } from "@/services/upload";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { base_URL } from "@/utils/http";
import { orderdetail, orderexpress } from "@/services/order";
// import wxicon from "../static/icon_weixin.png";
// import yeicon from "../static/icon_yue.png";
// import dficon from "../static/icon_daifu.png";

import wxicon from "@/static/cloudlibrary/icon_weixin.png";
import yeicon from "@/static/cloudlibrary/icon_yue.png";
import dficon from "@/static/cloudlibrary/icon_daifu.png";
import { productdel, orderpay, productconfirm } from "@/services/pay";
import { mine, isPayPassApi, checkPayPass } from "@/services/user";
import { formatPrice } from "@/utils/formatPrice";

const keyword = ref("");
const order_id = ref("");
const objdet = ref({});
const orderarr = ref([]);
const addresslist = ref([]);
const timeget = ref(0);
const addresslistshow = ref(false);

// 定义方法
onLoad((e) => {
  if (e.id) {
    order_id.value = e.id;
  } else {
  }
  getdetfun();
});

onShow(() => {
  isPayPassFun();
});
function clicktabs(item) {}

const searchfun = () => {
  console.lof(keyword.value);
};

async function getdetfun() {
  let res = await orderdetail({ order_id: order_id.value });
  orderarr.value = [];
  objdet.value = res.data;
  if (objdet.value.status == 0) {
    let data = new Date().getTime();
    let endata = new Date(res.data.pay_end_time_text).getTime();
    timeget.value = endata - data > 0 ? endata - data : 0;
  }

  if (objdet.value.status == 2 || objdet.value.status == 3) {
    try {
      let resaddress = await orderexpress({
        delivery_name: objdet.value.delivery_name,
        delivery_id: objdet.value.delivery_id,
      });
      addresslist.value = resaddress.data.data;
    } catch (e) {}
  }

  objdet.value.orderProduct.forEach((item, index) => {
    if (item.is_refund == 0 && item.refund_switch == 1) {
      orderarr.value.push({
        product_id: item.product_info.product_id,
        product_num: item.product_num,
      });
    }
  });
}

const index = ref(0);
const showOrder = ref(false);

const canlfun = (id) => {
  showOrder.value = true;
  order_id.value = id;
};

const closeOrder = () => {
  showOrder.value = false;
};

const goshopphone = (num) => {
  uni.makePhoneCall({
    phoneNumber: num, //仅为示例
  });
};
const goshopaddress = (lat, lng, name) => {
  console.log(lat, lng);
  uni.openLocation({
    latitude: Number(lat),
    longitude: Number(lng),
    name: name,
    success: function () {
      console.log("success");
    },
  });
};

const orderSubmit = async () => {
  try {
    let res = await productdel({ order_id: order_id.value });
    if (res.code == 200) {
      uni.showToast({
        title: "订单已取消",
        icon: "none",
      });
      showOrder.value = false;
      uni.redirectTo({ url: "/pages/order/orderlist/index?status=-2" });
      // getdetfun();
    }
  } catch (e) {
    uni.showToast({
      title: e.info,
      icon: "none",
    });
    showOrder.value = false;
  }
};

// 确认收货
const showqrshfun = ref(false);
const closeqrshfun = () => {
  showqrshfun.value = false;
};

const qrshfun = (id) => {
  showqrshfun.value = true;
  order_id.value = id;
};
const qrshfunSubmit = async () => {
  try {
    let res = await productconfirm({ order_id: order_id.value });
    if (res.code == 200) {
      uni.showToast({
        title: "已确认收货",
        icon: "none",
      });
      showqrshfun.value = false;
      getdetfun();
    }
  } catch (e) {
    uni.showToast({
      title: e.info,
      icon: "none",
    });
    showqrshfun.value = false;
  }
};

const balance = ref(0);
// 查询用户余额
const mineFun = async () => {
  try {
    // 发送请求
    let res = await mine();
    if (res.code == 200) {
      balance.value = res.data.balance;
      if (balance.value < total_price.value) {
        pay_type.value = 2;
      }
    }
  } catch (e) {
    uni.showToast({
      title: e.info,
      icon: "none",
    });
  }
};

const isPayPass = ref(0);
const isPayPassFun = async () => {
  try {
    let res = await isPayPassApi();
    if (res.code == 200) {
      isPayPass.value = res.data;
    }
  } catch (e) {
    uni.showToast({
      title: e.info,
      icon: "none",
    });
  }
};

const showPassword = ref(false);
const pay_pass = ref("");
const gopassword = () => {
  if (pay_type.value == 1 && balance.value < objdet.total_price) {
    uni.showToast({
      title: "余额不足，无法支付",
      icon: "success",
    });
    return;
  }

  if (pay_type.value == 1 && isPayPass.value != 0) {
    showPassword.value = true;
    pay_pass.value = "";
    setTimeout(() => {
      focusinput.value = true;
    }, 500);
  } else if (pay_type.value == 1 && isPayPass.value == 0) {
    uni.showToast({
      title: "没有支付密码，前往设置",
      icon: "none",
    });

    setTimeout(() => {
      uni.navigateTo({
        url: "/pages/mysetting/modify/index?isshowPassword=" + isPayPass.value,
      });
    }, 500);
  }
  if (pay_type.value == "2" || pay_type.value == "7") {
    gepaymentfun();
  }
};

//支付
const payshow = ref(false);
const payform = ref({
  order_id: "",
});

const total_price = ref(0);
const payfun = (item, index) => {
  // selectindex.value = index;
  payform.value.order_id = item.order_id;
  payshow.value = true;
  total_price.value = item.total_price;
  mineFun();
};
const paylist = ref([
  {
    title: "2",
    des: "微信支付（推荐）",
    icon: wxicon,
  },
  {
    title: "1",
    des: "余额支付 ",
    icon: yeicon,
  },
  // {
  //   title: "7",
  //   des: "他人代付",
  //   icon: dficon,
  // },
]);
const close = () => {
  payshow.value = false;
  showqrshfun.value = false;
  showOrder.value = false;
  showPassword.value = false;
  addresslistshow.value = false;
  focusinput.value = false;
  pay_pass.value = "";
};
const selectpayfun = async (type) => {
  if (balance.value < total_price.value && type == 1) {
    uni.showToast({
      title: "余额不足",
      icon: "none",
    });
    return;
  }
  pay_type.value = type;
};
function onBridgeReady(yishen, id) {
  WeixinJSBridge.invoke("getBrandWCPayRequest", yishen, (res) => {
    if (res) {
      getdetfun();
      // 使用以上方式判断前端返回,微信团队郑重提示：
      //res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
    }
  });
}
// const qrshfun = async () => {};
const gocancle = () => {
  showPassword.value = false;
  pay_pass.value = "";
};
const pay_type = ref(1);
const ispay = ref(false);
const gepaymentfun = async () => {
  let res = null;
  try {
    if (pay_type.value == "1") {
      // 防止小程序输入密码重复支付
      if (!ispay.value) {
        ispay.value = true;
      } else {
        return;
      }
      res = await orderpay({
        order_id: order_id.value,
        pay_type: 1,
        pay_pass: pay_pass.value,
      });
    }
    if (pay_type.value == "2") {
      // #ifdef H5 || APP-PLUS
      res = await orderpay({ order_id: order_id.value, pay_type: 2 });
      let yishen = JSON.parse(res.data.wxWcPayData);

      if (typeof WeixinJSBridge == "undefined") {
        if (document.addEventListener) {
          document.addEventListener(
            "WeixinJSBridgeReady",
            onBridgeReady(yishen),
            false
          );
        } else if (document.attachEvent) {
          document.attachEvent("WeixinJSBridgeReady", onBridgeReady(yishen));
          document.attachEvent("onWeixinJSBridgeReady", onBridgeReady(yishen));
        }
      } else {
        onBridgeReady(yishen);
      }

      // #endif
      // #ifdef MP-WEIXIN
      let res = await orderpay({ order_id: order_id.value, pay_type: 3 });
      if (res.code == 200) {
        // 仅作为示例，非真实参数信息。
        uni.requestPayment({
          provider: "wxpay",
          timeStamp: res.data.timeStamp,
          nonceStr: res.data.nonceStr,
          package: res.data.package,
          signType: res.data.signType,
          paySign: res.data.paySign,
          success: function (res) {
            getdetfun();
          },
          fail: function (err) {
            uni.showToast({
              title: "取消支付",
              icon: "none",
            });
          },
        });
      } else {
        uni.showToast({
          title: "支付失败",
          icon: "none",
        });
      }

      // #endif

      return;
    }
    if (pay_type.value == "7") {
      uni.navigateTo({
        url: "/pages/upgrade/payment/index?order_id=" + order_id.value,
      });
      return;
    }

    if (res.code == 200) {
      uni.showToast({
        title: "支付成功",
        icon: "none",
      });
      showPassword.value = false;
      focusinput.value = false;
      pay_pass.value = "";
      getdetfun();
      payshow.value = false;
    } else {
      uni.showToast({
        title: res.info,
        icon: "none",
      });
      pay_pass.value = "";
    }
  } catch (e) {
    if (typeof WeixinJSBridge == "undefined") {
      uni.showToast({
        title: "暂未开通微信支付！",
        icon: "none",
      });
      return;
    }
    uni.showToast({
      title: e.info,
      icon: "none",
    });
    pay_pass.value = "";
  }
};
// const gepaymentfun = async () => {
//   let res = null;

//   try {
//     if (pay_type.value == "1") {
//       res = await orderpay(payform.value);
//     }
//     if (pay_type.value == "2") {
//       res = await orderpay({ ...payform.value, pay_type: 2 });
//       let yishen = JSON.parse(res.data.wxWcPayData);

//       if (typeof WeixinJSBridge == "undefined") {
//         if (document.addEventListener) {
//           document.addEventListener(
//             "WeixinJSBridgeReady",
//             onBridgeReady(yishen, payform.value),
//             false
//           );
//         } else if (document.attachEvent) {
//           document.attachEvent(
//             "WeixinJSBridgeReady",
//             onBridgeReady(yishen, payform.value)
//           );
//           document.attachEvent(
//             "onWeixinJSBridgeReady",
//             onBridgeReady(yishen, payform.value)
//           );
//         }
//       } else {
//         onBridgeReady(yishen, payform.value);
//       }

//       return;
//     }
//     if (pay_type.value == "7") {
//       uni.navigateTo({
//         url: "/pages/upgrade/payment/index?order_id=" + payform.value.order_id,
//       });
//       return;
//     }

//     if (res.code == 200) {
//       uni.showToast({
//         title: "支付成功",
//         icon: "none",
//       });
//       getdetfun();
//       payshow.value = false;
//     } else {
//       uni.showToast({
//         title: e.info,
//         icon: "none",
//       });
//     }
//   } catch (e) {
//     payshow.value = false;
//     uni.showToast({
//       title: e.info,
//       icon: "none",
//     });
//   }
// };

const goorderdet = (id) => {
  uni.navigateTo({
    url: "/pages/order/orderdet/index?id=" + id,
  });
};

const alltkfun = (id) => {
  uni.navigateTo({
    url:
      "/pages/order/return/index?id=" +
      id +
      "&arr=" +
      JSON.stringify(orderarr.value),
  });
};
const tkfun = (id, item) => {
  uni.navigateTo({
    url:
      "/pages/order/return/index?id=" +
      id +
      "&arr=" +
      JSON.stringify([
        {
          product_id: item.product_info.product_id,
          product_num: item.product_num,
        },
      ]),
  });
};

const allshfun = (id) => {
  uni.navigateTo({
    url:
      "/pages/order/return/index?id=" +
      id +
      "&type=2" +
      "&arr=" +
      JSON.stringify(orderarr.value),
  });
};
const shfun = (id, item) => {
  uni.navigateTo({
    url:
      "/pages/order/return/index?id=" +
      id +
      "&type=2" +
      "&arr=" +
      JSON.stringify([
        {
          product_id: item.product_info.product_id,
          product_num: item.product_num,
        },
      ]),
  });
};
const showaddressshowfun = () => {
  addresslistshow.value = true;
};

const refunddetfun = (refund_id) => {
  if (!objdet.value.refund_id) {
    uni.showToast({
      title: "不存在订单id",
      icon: "none",
    });
    return;
  }

  uni.redirectTo({
    url: "/pages/order/returnwl/index?refund_id=" + objdet.value.refund_id,
  });
};

// 定义 finish 方法
const finish = async (e) => {
  pay_pass.value = e;
  try {
    let res = await checkPayPass({ pay_pass: pay_pass.value });
    if (res.code == 200) {
      gepaymentfun();
    }
  } catch (e) {
    uni.showToast({
      title: e.info,
      icon: "none",
    });
    pay_pass.value = "";
  }
};
const forgot = () => {
  uni.navigateTo({
    url: "/pages/mysetting/modify/index?isshowPassword=" + isPayPass.value,
  });
};
const focusinput = ref(false);
</script>

<template>
  <view class="content">
    <view class="header-list">
      <view class="header-list-title">
        <view class="header-list-title-arr"
          ><view v-if="objdet.paid == 0">{{
            objdet.status == 0 ? "待付款" : objdet.paid_text
          }}</view>
          <view v-if="objdet.paid == 1">{{
            objdet.status == 1 ? "待发货" : objdet.status_text
          }}</view>

          <view v-if="objdet.paid == 0">
            <text>剩余</text>
            <!-- :time="timeget" -->
            <up-count-down
              :time="objdet.auto_confirm_time * 1000"
              format="HH:mm:ss"
              autoStart
              millisecond
            ></up-count-down>
            <text>秒系统将自动取消订单</text>
          </view>

          <view v-if="objdet.status == 2">
            <text>剩余</text>
            <up-count-down
              :time="objdet.auto_confirm_time * 1000"
              format="DD:HH:mm:ss"
              autoStart
              millisecond
            >
            </up-count-down>
            <text>秒系统将自动收货</text>
          </view>
        </view>
        <image src="@/pages/order/static/icon1.png" mode="scaleToFill" />
      </view>
    </view>

    <view class="info-k">
      <view
        class="address-k"
        v-if="
          (objdet.status == 0 ||
            objdet.status == 1 ||
            objdet.status == 2 ||
            objdet.status == 3) &&
          (objdet.order_type == 0 || objdet.order_type == 3)
        "
      >
        <view class="address address-two">
          <view class="address-icom">
            <!-- <up-icon
              name="@/pages/order/static/shop.png"
              color="#8C8C8C"
              size="48rpx"
            ></up-icon> -->
            <image src="@/pages/order/static/shop.png" mode="scaleToFill" />
          </view>

          <view class="address-imgortext">
            <view class="address-img">
              <image :src="objdet.shop.images[0]" mode="appectFill"></image>
            </view>
            <view>
              <view class="address-title"
                ><text>{{ objdet.shop && objdet.shop.shop_name }}</text>
                <!-- <text class="address-title-phone">{{
                objdet.user_phone
              }}</text> -->
              </view>
              <view class="arrder-det">{{ objdet.shop.address }}</view>
              <view class="arrder-det"
                >营业时间: {{ objdet.shop.business_hours }}</view
              >
            </view>
          </view>
        </view>
        <view class="address-bt-to">
          <view class="address-bt-left" @click="goshopphone(objdet.shop.phone)">
            <up-icon name="phone" color="#8C8C8C" size="32rpx"></up-icon
            ><text>联系自提点</text></view
          >
          <view
            class="address-bt-right"
            @click="
              goshopaddress(
                objdet.shop.lat,
                objdet.shop.lng,
                objdet.shop.shop_name
              )
            "
          >
            <up-icon name="map" color="#8C8C8C" size="32rpx"></up-icon
            ><text>导航到自提点</text></view
          >
        </view>
      </view>
      <!-- <view
      class="address"
      v-if="
        objdet.status != 2 && (objdet.order_type == 0 || objdet.order_type == 3)
      "
    >
      <view class="address-icom">
        <up-icon name="map" color="#8C8C8C" size="48rpx"></up-icon>
      </view>
      <view>
        <view class="address-title"
          ><text>{{ objdet.real_name }}</text
          ><text class="address-title-phone">{{
            objdet.user_phone
          }}</text></view
        >
        <view class="arrder-det"
          >{{ objdet.order_region_text }}{{ objdet.order_address }}</view
        >
      </view>
    </view> -->
      <view class="list">
        <view class="list-item">
          <view class="list-item-title">
            <text>共{{ objdet.total_num }}件商品</text>
            <!-- <text class="list-item-title">待支付</text> -->
          </view>
          <view class="list-item-content">
            <view
              class="list-item-content-item"
              v-for="(item, index) in objdet.orderProduct"
              :key="index"
            >
              <view class="list-item-content-img">
                <image
                  :src="
                    item.product_info && item.product_info.image
                      ? item.product_info.image
                      : ''
                  "
                  mode=""
                ></image>
              </view>
              <view class="list-item-content-info">
                <view class="list-item-content-info-title">
                  <view class="good-name">
                    <text>{{
                      item.product_info && item.product_info.store_name
                        ? item.product_info.store_name
                        : ""
                    }}</text>
                  </view>
                  <view>
                    <text class="good-name-mr">默认</text>
                  </view>
                </view>
                <view class="list-item-price">
                  <view
                    >¥{{
                      formatPrice(
                        item.product_info && item.product_info.price
                          ? item.product_info.price
                          : ""
                      )
                    }}</view
                  >
                  <view class="good-name-num"
                    >x{{ item.product_num ? item.product_num : "" }}</view
                  >
                  <view
                    class="good-name-num-text-type"
                    v-if="item.is_refund != 0"
                    >{{
                      item.refund_status_text ? item.refund_status_text : ""
                    }}</view
                  >
                  <view
                    class="list-item-btn-item-left-btn list-item-btn-item-left-btn-two"
                    @click="refunddetfun(item)"
                    v-if="item.is_refund != 0"
                    >查看</view
                  >
                </view>
                <view
                  class="list-item-btn-item-left-btn"
                  v-if="
                    item.is_refund == 0 &&
                    objdet.status == 1 &&
                    item.refund_switch == 1 &&
                    objdet.order_type == 0
                  "
                  @click="tkfun(objdet.order_id, item)"
                  >退款</view
                >
                <view
                  class="list-item-btn-item-left-btn"
                  v-if="
                    item.is_refund == 0 &&
                    objdet.status == 2 &&
                    item.refund_switch == 1 &&
                    objdet.order_type == 0
                  "
                  @click="shfun(objdet.order_id, item)"
                  >退款</view
                >
                <view
                  class="list-item-btn-item-left-btn"
                  v-if="
                    item.is_refund == 0 &&
                    objdet.status == 3 &&
                    item.refund_switch == 1 &&
                    objdet.order_type == 0
                  "
                  @click="shfun(objdet.order_id, item)"
                  >退款</view
                >
              </view>
            </view>
            <!-- <view class="list-item-content-item">
            <view class="list-item-content-img">
              <image src="/static/images/1.png" mode="widthFix"></image>
            </view>
            <view class="list-item-content-info">
              <view class="list-item-content-info-title">
                <view class="good-name">
                  <text>经销商升级大礼包套餐商升级大礼升级大礼升级...</text>
                </view>
                <view>
                  <text class="good-name-mr">默认</text>
                </view>
              </view>
              <view class="list-item-price">
                <view>¥2000</view>
                <view class="good-name-num">x1</view>
              </view>

              <view class="list-item-btn-item-left-btn">取消订单</view>
            </view>
          </view> -->
          </view>
          <view class="list-xq">
            <view class="list-xq-item">
              <text>运费</text>
              <text>0.00</text>
            </view>
            <view class="list-xq-item">
              <text>合计</text>
              <text class="colors"
                >¥{{ formatPrice(objdet.total_price || 0) }}</text
              >
            </view>
          </view>
          <!-- <view class="list-nums">
          <text>共1件, </text>
          <text>总计：</text><text class="list-nums-s">¥2000</text>
        </view>
        <view class="list-item-btn">
          <view class="list-item-btn-item-left">取消订单</view>
          <view class="list-item-btn-item-right">立即支付</view>
        </view> -->
        </view>
      </view>

      <view class="list-det">
        <view class="list-det-item">
          <view class="list-det-item-list">订单编号</view>
          <view class="list-det-item-list list-det-item-list2">
            {{ objdet.order_id || "" }}
            <up-copy :content="objdet.order_id">
              <image
                src="@/pages/order/static/copy-img.png"
                mode="scaleToFill"
              />
            </up-copy>
          </view>
        </view>
        <view class="list-det-item">
          <view class="list-det-item-list">订单类型</view>
          <view class="list-det-item-list">
            {{ objdet.order_type_text || "---" }}
            <!-- <up-copy :content="objdet.order_id">
            <image src="@/pages/order/static/copy-img.png" mode="scaleToFill" />
          </up-copy> -->
          </view>
        </view>
        <view class="list-det-item">
          <view class="list-det-item-list">下单时间</view>
          <view class="list-det-item-list-right">{{
            objdet.create_time ? objdet.create_time : "---"
          }}</view>
        </view>
        <view class="list-det-item">
          <view class="list-det-item-list">付款方式</view>
          <view class="list-det-item-list-right">{{
            objdet.pay_type_text || "---"
          }}</view>
        </view>
        <view class="list-det-item">
          <view class="list-det-item-list">付款时间</view>
          <view class="list-det-item-list-right">{{
            objdet.pay_time || "---"
          }}</view>
        </view>
        <view class="list-det-item">
          <view class="list-det-item-list">配送方式</view>
          <view class="list-det-item-list-right">{{
            objdet.order_delivery_type == 1 ? "快递" : "自提"
          }}</view>
        </view>
        <view
          class="list-det-item"
          v-if="objdet.delivery && objdet.delivery.type_text"
        >
          <view class="list-det-item-list">发货方式</view>
          <view class="list-det-item-list-right">{{
            objdet.delivery && objdet.delivery.type_text
              ? objdet.delivery.type_text
              : "--"
          }}</view>
        </view>
        <view class="list-det-item">
          <view class="list-det-item-list">备注</view>
          <view class="list-det-item-list-right">{{
            objdet.mark ? objdet.mark : "---"
          }}</view>
        </view>
      </view>
    </view>
  </view>

  <view
    class="content-footer"
    v-if="objdet.status == 1 && orderarr.length > 0 && objdet.order_type == 0"
  >
    <view class="contebt-pays">
      <view class="pay-bt-xs" @click="alltkfun(objdet.order_id)">全部退款</view>
    </view>
  </view>
  <view
    class="content-footer"
    v-if="
      (objdet.status == 2 && orderarr.length > 0 && objdet.order_type == 0) ||
      (objdet.status == 2 && addresslist.length > 0)
    "
  >
    <view class="contebt-pays">
      <view
        v-if="
          addresslist.length > 0 || objdet.status == 2 || objdet.status == 3
        "
        class="pay-bt-xs"
        @click="showaddressshowfun()"
        >查看物流</view
      >
      <view
        v-if="orderarr.length > 0"
        class="pay-bt-xs"
        @click="allshfun(objdet.order_id)"
        >全部退款</view
      >
      <view
        v-if="objdet.status == 2"
        @click="qrshfun(objdet.order_id)"
        class="pay-bt pay-df"
        >确认收货</view
      >
    </view>
  </view>
  <view
    class="content-footer"
    v-if="
      (objdet.status == 3 && orderarr.length > 0 && objdet.order_type == 0) ||
      (objdet.status == 3 && addresslist.length > 0)
    "
  >
    <view class="contebt-pays">
      <view
        v-if="
          addresslist.length > 0 || objdet.status == 2 || objdet.status == 3
        "
        class="pay-bt-xs"
        @click="showaddressshowfun()"
        >查看物流</view
      >
      <view
        v-if="orderarr.length > 0"
        class="pay-bt-xs"
        @click="allshfun(objdet.order_id)"
        >全部退款</view
      >
    </view>
  </view>

  <!-- <view class="content-footer" v-if="objdet.status == 4 && orderarr.length > 0">
    <view class="contebt-pays">
      <up-button
        v-if="addresslist.length > 0"
        class="pay-bt-xs"
        @click="showaddressshowfun()"
        text="查看物流"
      ></up-button>
    </view>
  </view> -->

  <view class="content-footer" v-else-if="objdet.status == 0">
    <view class="contebt-pays">
      <!-- <view
            class="list-item-btn-item-left"
            v-if="item.paid == 0"
            @click="canlfun(item.order_id, index)"
            >取消订单</view
          >
          <view
            class="list-item-btn-item-left"
            v-if="item.status == 1"
            @click="tkfun(item.order_id, index)"
            >退款</view
          >
          <view
            v-if="item.paid == 0"
            class="list-item-btn-item-right"
            @click="payfun(item.order_id, index)"
            >立即支付</view
          >
          <view
            v-if="item.status == 2"
            class="list-item-btn-item-right"
            @click="qrshfun(item.order_id, index)"
            >确认收货</view
          > -->

      <view
        class="pay-bt-xs"
        v-if="objdet.paid == 0"
        @click="canlfun(objdet.order_id)"
        >取消</view
      >

      <view
        v-if="objdet.paid == 0"
        @click="payfun(objdet)"
        class="pay-bt pay-df"
        >去支付</view
      >
    </view>
  </view>

  <up-popup v-model:show="payshow" :round="10" @close="close">
    <view class="content-pay">
      <view></view>
      <view
        class="content-pay-item"
        v-for="(item, index) in paylist"
        :key="index"
        @click="selectpayfun(item.title)"
      >
        <view
          :class="
            balance < total_price && item.title == 1
              ? 'content-pay-left noselect'
              : 'content-pay-left'
          "
        >
          <image :src="item.icon" mode="widthFix" />
          <text>{{ item.des }}</text>
          {{ item.title == 1 ? "(可用" + balance + "元)" : "" }}
        </view>
        <view class="content-pay-right" v-if="pay_type == item.title">
          <image src="@/pages/order/static/select.png" mode="widthFix" />
        </view>
      </view>
      <up-button
        @click="gopassword"
        class="custom-style"
        text="确认支付"
      ></up-button>
    </view>
  </up-popup>

  <!-- 密码弹框 -->
  <view class="password_show">
    <u-popup
      :show="showPassword"
      mode="center"
      round="10"
      @close="close"
      @open="open"
    >
      <view class="password">
        <view class="popup-content-title">支付密码</view>
        <u-code-input
          v-model="pay_pass"
          :maxlength="6"
          dot
          size="80"
          @change="onChange"
          @finish="finish"
          :focus="focusinput"
        ></u-code-input>
        <view class="footer">
          <view class="closefun" @click="showPassword = false">取消</view>
          <view class="forgot" @click="forgot">忘记密码？</view>
        </view>
      </view>
    </u-popup>
  </view>

  <up-popup
    v-model:show="addresslistshow"
    round="20"
    @close="close"
    :closeable="true"
    :closeOnClickOverlay="true"
  >
    <view class="addresscontent">
      <view class="addresscontent-content" v-if="addresslist.length <= 0">
        查询不到物流信息
      </view>
      <view class="addresscontent-two">
        <up-steps current="0" direction="column">
          <up-steps-item
            v-for="(item, index) in addresslist"
            :key="index"
            :title="item.context"
            :desc="item.time"
          >
          </up-steps-item>
        </up-steps>
      </view>
    </view>
  </up-popup>

  <!-- 取消订单弹框 -->
  <view class="password_show">
    <u-popup
      :show="showOrder"
      mode="center"
      round="10"
      @close="close"
      @open="open"
    >
      <view class="productGift">
        <view class="popup-content-title">温馨提示</view>
        <view class="popup-content-item"
          >取消订单无法回退，请确认取消订单？</view
        >
        <view class="popup-content-box">
          <view class="popup-content-bt">
            <view class="popup-content-qx" @click="closeOrder">取消</view>
            <view class="popup-content-cl" @click="orderSubmit">确定</view>
          </view>
        </view>
      </view>
    </u-popup>
  </view>

  <!-- 确认收货弹框 -->
  <view class="password_show">
    <u-popup
      :show="showqrshfun"
      mode="center"
      round="10"
      @close="close"
      @open="open"
    >
      <view class="productGift">
        <view class="popup-content-title">温馨提示</view>
        <view class="popup-content-item">确认收货无法回退，是否确认收货？</view>
        <view class="popup-content-box">
          <view class="popup-content-bt">
            <view class="popup-content-qx" @click="closeqrshfun">取消</view>
            <view class="popup-content-cl" @click="qrshfunSubmit">确定</view>
          </view>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<style lang="scss" scoped>
@import "./index.scss";
</style>
